package com.nineclock.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nineclock.system.pojo.SysRole;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;


public interface SysRoleMapper extends BaseMapper<SysRole> {

    /**
     * 根据员工id查询对应的角色列表
     * @param companyUserId
     * @return
     */
    @Select("select r.* from sys_company_user_role cur " +
            "INNER JOIN sys_role r on cur.role_id = r.id where cur.company_user_id = #{companyUserId}")
    public List<SysRole> queryRoleByCompanyUserId(@Param("companyUserId") Long companyUserId);

    @Select("select cur.company_user_id,r.role_desc from sys_company_user_role cur \n" +
            "INNER JOIN sys_role r\n" +
            "on cur.role_id = r.id\n" +
            "where r.role_name like \"ROLE_ADMIN%\" AND cur.company_user_id = #{companyUserId}")
    public List<SysRole> queryRoleByAdminId(@Param("companyUserId") Long companyUserId);
}
